package com.tcm.user.dao;

import com.tcm.user.model.entity.LoginAuth;
import org.apache.ibatis.annotations.Param;

import java.util.List;

public interface LoginAuthMapper {

    int insert(LoginAuth record);

    int update(LoginAuth record);

    /**
     * 删除会员
     * @param userId 主键id
     * @return
     */
    int deleteByUserId(@Param("userId")Long userId, @Param("clientType") String clientType);

    int deleteLogicByUserId(@Param("userId")Long userId, @Param("clientType") String clientType);

    LoginAuth findByUsername(@Param("username")String username, @Param("clientType") String clientType);

    LoginAuth findByMobile(@Param("mobile")String mobile, @Param("clientType") String clientType);

    List<LoginAuth> queryByMobile(@Param("mobileList") List<String> mobileList, @Param("clientType") String clientType);

    LoginAuth findByUserId(@Param("userId")Long userId, @Param("clientType") String clientType);

    LoginAuth queryUser(LoginAuth loginAuth);

    /**
     * 修改密码凭证
     * @param userId
     * @return
     */
    int changeCredential(@Param("userId")Long userId, @Param("password") String password, @Param("clientType") String clientType);

    /**
     * 修改手机号
     * @param userId
     * @param mobile
     * @param clientType
     */
    void updateMobile(@Param("userId")Long userId, @Param("mobile") String mobile, @Param("clientType") String clientType);

    /**
     * 修改手机号
     * @param userId
     * @param username
     * @param clientType
     */
    void updateUsername(@Param("userId")Long userId, @Param("username") String username, @Param("clientType") String clientType);

    /**
     * 检查更新用户名时，是否账号唯一
     * @param userId
     * @param username
     * @param clientType
     * @return
     */
    LoginAuth checkUsernameExists(@Param("userId")Long userId, @Param("username") String username, @Param("clientType") String clientType);

    /**
     * 检查更新登录手机号时候，手机号是否唯一
     * @param userId
     * @param mobile
     * @param clientType
     * @return
     */
    LoginAuth checkMobileExists(@Param("userId")Long userId, @Param("mobile") String mobile, @Param("clientType") String clientType);
}